package uqbar.comm;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

import uqbar.comm.protocol.Output;


public class Request<Response> {

	private final int nextId;
	private final Output output;
	private final Lock lock;
	private final Condition condition;
	private Response response;

	public Request(final int nextId, final Output output, final Lock lock, final Condition condition) {
		this.nextId = nextId;
		this.output = output;
		this.lock = lock;
		this.condition = condition;
	}

	public Response getResponse() {
		return this.response;
	}

	public void setResponse(final Response response) {
		this.lock.lock();
		try {
			this.response = response;
			this.response = response;
			this.condition.signal();
		} finally {
			this.lock.unlock();
		}
	}

}
